package com.srd.phone.bean;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/5/25.
 */
public class TenderRewardInfo implements Serializable {

    public int id;
    public int ouotId;
    public int did;
    public String ctime;
    public String nm;
    public String dName;

    public static List<TenderRewardInfo> parseRewardType(String json) {
        List<TenderRewardInfo> list = new ArrayList<>();
        try {
            JSONArray jsonArray = new JSONArray(json);
            for (int i = 0; i < jsonArray.length(); i++) {
                JSONObject jsonObject = jsonArray.getJSONObject(i);
                TenderRewardInfo info = new TenderRewardInfo();
                info.id = jsonObject.optInt("id");
                info.ouotId = jsonObject.optInt("ouotId");
                info.did = jsonObject.optInt("did");
                info.ctime = jsonObject.optString("ctime");
                info.nm = jsonObject.optString("nm");
                info.dName = jsonObject.optString("dName");
                list.add(info);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return list;
    }

    public static List<RewareMoneyInfo> parseRewardMoney(String json) {
        List<RewareMoneyInfo> list = new ArrayList<>();
        try {
            JSONArray jsonArray = new JSONArray(json);
            for (int i = 0; i < jsonArray.length(); i++) {
                RewareMoneyInfo moneyInfo = new RewareMoneyInfo();
                JSONObject jsonObject = jsonArray.getJSONObject(i);
                moneyInfo.id = jsonObject.optInt("id");
                moneyInfo.state = jsonObject.optInt("state");
                moneyInfo.uid = jsonObject.optInt("uid");
                moneyInfo.nm = jsonObject.optString("nm");
                moneyInfo.stime = jsonObject.optString("stime");
                moneyInfo.ctime = jsonObject.optString("ctime");
                moneyInfo.tyid = jsonObject.optInt("tyid");
                moneyInfo.money = jsonObject.optString("money");
                moneyInfo.lower = jsonObject.optDouble("lower",0);
                moneyInfo.hid = jsonObject.optInt("hid");
                moneyInfo.isover = jsonObject.optString("isover");
                moneyInfo.hnm = jsonObject.optString("hnm");
                list.add(moneyInfo);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return list;
    }


    public static class RewareMoneyInfo {

        public int id;
        public int state;
        public int uid;
        public String nm;
        public String stime;
        public String ctime;
        public int tyid;
        public String money;
        public double lower;
        public int hid;
        public String isover;
        public String hnm;
    }
}
